/*
 * NewDialog.java
 *
 * Created on July 28, 2003, 4:47 PM
 */

import java.io.*;
import javax.swing.*;
/**
 *
 * @author  Hariprasad
 */
class NewDialog extends javax.swing.JDialog {
    
    /** Creates new form NewDialog */
    public NewDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();     
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        CDPanel = new javax.swing.JPanel();
        CDLabel = new javax.swing.JLabel();
        CDInfoLabel = new javax.swing.JLabel();
        CDLabelField = new javax.swing.JTextField();
        CDInfoField = new javax.swing.JTextField();
        AddCDButton = new javax.swing.JButton();
        CDCloseButton = new javax.swing.JButton();
        CDImageLabel = new javax.swing.JLabel();
        CDImageField = new javax.swing.JTextField();
        CDImageBrowse = new javax.swing.JButton();
        CDContentsLabel = new javax.swing.JLabel();
        CDContentsCombo = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("New");
        setModal(true);
        setName("NewDialog");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        CDPanel.setLayout(null);

        CDLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        CDLabel.setText("CD Label");
        CDPanel.add(CDLabel);
        CDLabel.setBounds(70, 50, 70, 16);

        CDInfoLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        CDInfoLabel.setText("CD Info");
        CDPanel.add(CDInfoLabel);
        CDInfoLabel.setBounds(70, 80, 70, 16);

        CDPanel.add(CDLabelField);
        CDLabelField.setBounds(180, 50, 120, 20);

        CDPanel.add(CDInfoField);
        CDInfoField.setBounds(180, 80, 120, 20);

        AddCDButton.setFont(new java.awt.Font("Dialog", 0, 12));
        AddCDButton.setText("Add");
        AddCDButton.setToolTipText("Add the CD data");
        AddCDButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddCDButtonActionPerformed(evt);
            }
        });

        CDPanel.add(AddCDButton);
        AddCDButton.setBounds(100, 230, 70, 26);

        CDCloseButton.setFont(new java.awt.Font("Dialog", 0, 12));
        CDCloseButton.setText("Close");
        CDCloseButton.setToolTipText("Close this dialog");
        CDCloseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CDCloseButtonActionPerformed(evt);
            }
        });

        CDPanel.add(CDCloseButton);
        CDCloseButton.setBounds(200, 230, 70, 26);

        CDImageLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        CDImageLabel.setText("CD Image");
        CDPanel.add(CDImageLabel);
        CDImageLabel.setBounds(70, 110, 80, 16);

        CDPanel.add(CDImageField);
        CDImageField.setBounds(180, 110, 100, 20);

        CDImageBrowse.setText("Browse");
        CDImageBrowse.setToolTipText("Browse for Image file");
        CDPanel.add(CDImageBrowse);
        CDImageBrowse.setBounds(280, 110, 20, 20);

        CDContentsLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        CDContentsLabel.setText("CD Contents");
        CDPanel.add(CDContentsLabel);
        CDContentsLabel.setBounds(70, 140, 80, 16);

        CDContentsCombo.setFont(new java.awt.Font("Dialog", 0, 12));
        CDContentsCombo.setToolTipText("Select CD Drive");
        CDPanel.add(CDContentsCombo);
        CDContentsCombo.setBounds(180, 140, 120, 20);

        getContentPane().add(CDPanel, java.awt.BorderLayout.CENTER);

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setSize(new java.awt.Dimension(400, 300));
        setLocation((screenSize.width-400)/2,(screenSize.height-300)/2);
    }//GEN-END:initComponents

    private void CDCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CDCloseButtonActionPerformed
        // Add your handling code here:
        this.dispose();
        CDLibrary.CDTable.revalidate();
    }//GEN-LAST:event_CDCloseButtonActionPerformed

    private void AddCDButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddCDButtonActionPerformed
        // Add your handling code here:
        String CDLabel=CDLabelField.getText();
        String CDInfo=CDInfoField.getText();
        if(CDLabel.length()!=0 && CDInfo.length()!=0)
        {
            CdClass cd=new CdClass(CDLabel,CDInfo);
            CDLibrary.Cds.addElement(cd.getVector());
        }
        else
            JOptionPane.showMessageDialog(null,"You have to enter some information");
        CDLabelField.setText(null);
        CDInfoField.setText(null);        
    }//GEN-LAST:event_AddCDButtonActionPerformed
/*
    private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkButtonActionPerformed
        // Add your handling code here:
        this.dispose();        
        CDLibrary.CDTable.revalidate();
    }//GEN-LAST:event_OkButtonActionPerformed
*/    
    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        setVisible(false);
        dispose();
    }//GEN-LAST:event_closeDialog
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new NewDialog(new javax.swing.JFrame(), true).show();
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CDCloseButton;
    private javax.swing.JTextField CDImageField;
    private javax.swing.JLabel CDContentsLabel;
    private javax.swing.JComboBox CDContentsCombo;
    private javax.swing.JLabel CDImageLabel;
    private javax.swing.JLabel CDInfoLabel;
    private javax.swing.JTextField CDLabelField;
    private javax.swing.JLabel CDLabel;
    private javax.swing.JPanel CDPanel;
    private javax.swing.JButton CDImageBrowse;
    private javax.swing.JTextField CDInfoField;
    private javax.swing.JButton AddCDButton;
    // End of variables declaration//GEN-END:variables
    
}
